** Replication materials for "Female Officeholders and Women's Political Engagement: The Role of Parties"
** Analyses testing for role model effects at level of candidacies for Mexican SMD deputies (2009-2015)
** Author: Oscar Castorena
** Data: roleModelEffects_Candidates.dta
** Tables replicated with this do file: Tables 2, A9, A10

* File path of data here
cd "C:\Users\castoro\Documents\"

use roleModelEffects_Candidates.dta, clear 

** Time-series cross-sectional analyses of candidacies
* panel-corrected standard errors with lagged dv
xtset district_id year, delta(3)
eststo clear
eststo: xtpcse pct_women pct_women_lag pct_women_neighbors_sl woman_win_lag i.winning_party_lag
eststo: xtpcse pct_women pct_women_lag pct_women_neighbors_sl woman_win_lag i.winning_party_lag i.year
* fixed effects
eststo: xtreg pct_women pct_women_neighbors_sl woman_win_lag i.winning_party_lag i.year, fe
generate sample = e(sample)
* latex table (Table 2)
esttab using tscsTable.tex, replace se r2 label nobaselevels varwidth(36) ///
title("Models of the Percent of Female Candidates in a District (2009-2015)"\label{tab:tscsResults}) nonotes ///
addnotes("For models (1) and (2), Prais-Winsten regression coefficients with panel corrected standard" ///
"errors in parentheses. For model (3), district dummies are not reported." ///
"* \emph{p} $<$ 0.05, ** \emph{p} $<$ 0.01, *** \emph{p} $<$ 0.001") 

* Descriptive stats for time-series cross-sectional data analysis (Table A9)
eststo clear
estpost summ pct_women pct_women_lag pct_women_neighbors_sl woman_win_lag pan_win_lag prd_win_lag pri_win_lag if sample == 1
esttab using descriptivestatsTSCS.tex, cell("mean(fmt(%12.2f)) sd(fmt(%12.2f)) min(fmt(%12.0f)) max(fmt(%12.0f)) count(fmt(%12.0f))") ///
title("Descriptive Statistics for Time-Series Cross-Sectional Election Analysis"\label{tab:tscsDescStats}) ///
nonumber nomtitle noobs label replace

** PAN-specific analysis (Table A10)
eststo clear
eststo: xtlogit pan_woman pan_woman_win_lag pct_pan_women_win_sl i.year, fe
* latex table 
esttab using tscsTablePAN.tex, replace se pr2 label nobaselevels varwidth(36) mtitles("PAN Female Candidate") ///
title("Logistic Fixed Effects Model of PAN Female Candidate in a District (2009-2015)"\label{tab:tscsResultsPAN})
